package com.polaris.live.ui.main.fragment

import androidx.recyclerview.widget.LinearLayoutManager
import com.polaris.live.R
import com.polaris.live.adapter.home.HomeWomanAdapter
import com.polaris.live.constant.UserConst
import com.polaris.live.databinding.FragmentHotWomanBinding
import com.polaris.live.resp.back_resp.DisplayUserBean
import com.polaris.live.utils.StartMessageProxy
import com.polaris.live.utils.interfaces.OnAutoRefreshListener
import com.polaris.live.utils.interfaces.OnRefreshStateListener
import com.polaris.live.viewmodel.home.HotViewModel

/**
 * 热门主页-女
 *
 * @author Created by lucas on 2023/10/16 13:32
 * @since 1.0.0
 */
class HotWomanFragment : AbstractHotListFragment<HotViewModel, FragmentHotWomanBinding>(),
    OnAutoRefreshListener, OnRefreshStateListener {

    override val refreshView by lazy { mBinding.refresh }

    override val layoutManager by lazy { LinearLayoutManager(context) }

    override val mAdapter by lazy { HomeWomanAdapter() }

    override val listLiveData by lazy { mViewModel.listLiveData }

    override fun initListener() {
        mAdapter.setOnItemChildClickListener { _, view, position ->
            val item = mAdapter.getItem(position)
            if (item is DisplayUserBean) {
                when (view.id) {
                    R.id.cl_invite -> {
                        StartMessageProxy.gotoMessage(
                            requireActivity(),
                            UserConst.From.HOT,
                            item.base
                        )
                    }
                }
            }
        }
    }

    override fun onRefreshState() {
        if (!isCreated()) return
    }
}